package com.wfg.beanpostprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.PriorityOrdered;
import org.springframework.stereotype.Component;

/**
 * spring
 *
 * @Title: com.wfg.beanpostprocessor
 * @Date: 2020/12/29 0029 23:11
 * @Author: wfg
 * @Description:
 * @Version:
 */
@Component
public class TestBeanPostProcessor02 implements BeanPostProcessor, PriorityOrdered {
	/**
	 * 初始化之前调用
	 * @param bean the new bean instance
	 * @param beanName the name of the bean
	 * @return
	 * @throws BeansException
	 */
	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		System.out.println(beanName+this.getClass().getSimpleName());
		return bean;
	}

	/**
	 * 初始化之后调用
	 * @param bean the new bean instance
	 * @param beanName the name of the bean
	 * @return
	 * @throws BeansException
	 */
	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println(beanName+this.getClass().getSimpleName());
		return bean;
	}

	@Override
	public int getOrder() {
		return 0;
	}
}
